package org.smr.ministore.service.impl;

import java.util.List;

import org.blade.dao.base.BaseMapper;
import org.blade.utils.IdGenUtils;
import org.blade.utils.Pager;
import org.blade.service.base.AbstractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.dao.BrandOrganMapper;
import org.smr.ministore.entities.BrandOrgan;
import org.smr.ministore.entities.vo.BrandOrganQuery;
import org.smr.ministore.service.BrandOrganService;

import org.smr.ministore.service.BrandService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("brandOrganServiceFacade")
public class BrandOrganServiceFacade extends AbstractService<Long, BrandOrgan> implements BrandOrganService {

    private static Logger logger = LoggerFactory.getLogger(BrandOrganServiceFacade.class);

    @Resource(name = "brandOrganServiceImpl")
    private BrandOrganService service;

    @Resource(name = "brandServiceImpl")
    private BrandService brandService;

    @Autowired
    public BrandOrganServiceFacade(BrandOrganMapper mapper) {
        super(mapper);
    }

    public int save(BrandOrgan entity) {

        int effect = brandService.save(entity.getBrand());
        if(effect == BrandOrgan.EFFECT_FUSE) {
            return BrandOrgan.EFFECT_FUSE;
        }
        return service.save(entity);
    }

    public int updateById(BrandOrgan id) {
        return service.updateById(id);
    }

    public BrandOrgan queryById(Long id) {
        BrandOrgan brandOrgan = service.queryById(id);
        return service.queryById(id);
    }

    public int deleteById(Long id) {
        return service.deleteById(id);
    }

    public Pager<BrandOrgan> paginate(BrandOrgan entity, Long pageSize, Long pageNum) {

        return service.paginate(entity, pageSize, pageNum);
    }

    public int batchSave(List<BrandOrgan> entities) {
        return service.batchSave(entities);
    }


    public int batchModify(List<BrandOrgan> entities) {
        return service.batchModify(entities);
    }


    public int deleteByIdLogical(Long id) {
        return service.deleteByIdLogical(id);
    }

    public BrandOrgan queryBy(BrandOrgan brandOrgan) {
        return service.queryBy(brandOrgan);
    }

    public List<BrandOrgan> queryAlreadyAssignedOrgans(BrandOrganQuery brandOrganQuery) {
        return this.service.queryAlreadyAssignedOrgans(brandOrganQuery);
    }


    public Long getId() {
        return IdGenUtils.getNextLongId();
    }
}
